#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e6+10;

char a[MAXN],b[MAXN];
int nxt[MAXN],n,m;

int main (){
	scanf("%s",b+1); scanf("%s",a+1);
	n = strlen(a+1),m = strlen(b+1);
	nxt[1] = 0;
	for(int i = 2,j = 0;i <= n;i++){
		while(j && a[j+1] != a[i]) j = nxt[j];
		if(a[j+1] == a[i]) j++;
		nxt[i] = j;
	}
	for(int i = 1,j = 0;i <= m;i++){
		while(j && (j == n || a[j+1] != b[i])) j = nxt[j];
		if(a[j+1] == b[i]) j++;
		if(j == n) printf("%d\n",i-n+1);
	}
	for(int i = 1;i <= n;i++) printf("%d ",nxt[i]);
	return 0;
}
